home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / flyout / form2.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-07  |  10.1 KB  |  305 lines

  1. VERSION 2.00
  2. Begin Form frmFlyout 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    ClientHeight    =   1725
  6.    ClientLeft      =   3630
  7.    ClientTop       =   1635
  8.    ClientWidth     =   2085
  9.    ControlBox      =   0   'False
  10.    Height          =   2130
  11.    Left            =   3570
  12.    LinkTopic       =   "Form2"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   115
  16.    ScaleMode       =   3  'Pixel
  17.    ScaleWidth      =   139
  18.    Top             =   1290
  19.    Width           =   2205
  20.    Begin PictureBox SubClass1 
  21.       Height          =   480
  22.       Left            =   100
  23.       ScaleHeight     =   450
  24.       ScaleWidth      =   1170
  25.       TabIndex        =   0
  26.       Top             =   80
  27.       Width           =   1200
  28.    End
  29.    Begin Image Image1 
  30.       Height          =   330
  31.       Index           =   15
  32.       Left            =   0
  33.       Top             =   900
  34.       Width           =   360
  35.    End
  36.    Begin Image Image1 
  37.       Height          =   330
  38.       Index           =   14
  39.       Left            =   1440
  40.       Top             =   600
  41.       Width           =   360
  42.    End
  43.    Begin Image Image1 
  44.       Height          =   330
  45.       Index           =   13
  46.       Left            =   1080
  47.       Top             =   600
  48.       Width           =   360
  49.    End
  50.    Begin Image Image1 
  51.       Height          =   330
  52.       Index           =   12
  53.       Left            =   720
  54.       Top             =   600
  55.       Width           =   360
  56.    End
  57.    Begin Image Image1 
  58.       Height          =   330
  59.       Index           =   11
  60.       Left            =   360
  61.       Top             =   600
  62.       Width           =   360
  63.    End
  64.    Begin Image Image1 
  65.       Height          =   330
  66.       Index           =   10
  67.       Left            =   0
  68.       Top             =   600
  69.       Width           =   360
  70.    End
  71.    Begin Image Image1 
  72.       Height          =   330
  73.       Index           =   9
  74.       Left            =   1440
  75.       Top             =   300
  76.       Width           =   360
  77.    End
  78.    Begin Image Image1 
  79.       Height          =   330
  80.       Index           =   8
  81.       Left            =   1080
  82.       Top             =   300
  83.       Width           =   360
  84.    End
  85.    Begin Image Image1 
  86.       Height          =   330
  87.       Index           =   7
  88.       Left            =   720
  89.       Top             =   300
  90.       Width           =   360
  91.    End
  92.    Begin Image Image1 
  93.       Height          =   330
  94.       Index           =   6
  95.       Left            =   360
  96.       Top             =   300
  97.       Width           =   360
  98.    End
  99.    Begin Image Image1 
  100.       Height          =   330
  101.       Index           =   5
  102.       Left            =   0
  103.       Top             =   300
  104.       Width           =   360
  105.    End
  106.    Begin Image Image1 
  107.       Height          =   330
  108.       Index           =   4
  109.       Left            =   1440
  110.       Top             =   0
  111.       Width           =   360
  112.    End
  113.    Begin Image Image1 
  114.       Height          =   330
  115.       Index           =   3
  116.       Left            =   1080
  117.       Top             =   0
  118.       Width           =   360
  119.    End
  120.    Begin Image Image1 
  121.       Height          =   330
  122.       Index           =   2
  123.       Left            =   720
  124.       Top             =   0
  125.       Width           =   360
  126.    End
  127.    Begin Image Image1 
  128.       Height          =   330
  129.       Index           =   1
  130.       Left            =   360
  131.       Top             =   0
  132.       Width           =   360
  133.    End
  134.    Begin Image Image1 
  135.       Height          =   330
  136.       Index           =   0
  137.       Left            =   0
  138.       Top             =   0
  139.       Width           =   360
  140.    End
  141. Option Explicit
  142. Dim LastIndexPressed%
  143. Sub Form_Load ()
  144.    ' Set the form's global var LastIndexPressed% to -1.
  145.    LastIndexPressed% = -1
  146. End Sub
  147. Sub SubClass1_WndMessage (wnd As Integer, msg As Integer, wp As Integer, lp As Long, retval As Long, nodef As Integer)
  148.    Dim x%                        ' X coordinate of the mouse
  149.    Dim y%                        ' Y coordinate of the mouse
  150.    Dim row%                      ' Icon row the mouse is over
  151.    Dim column%                   ' Icon column the mouse is over
  152.    Dim image_num%                ' The index of the icon the mouse is over
  153.    Dim temp_str$                 ' Temp var
  154.    Dim temp%                     ' Temp var
  155.    ' Based on the message received...
  156.    Select Case (msg)
  157.       '
  158.       ' Mouse has moved.
  159.       '
  160.       Case WM_MOUSEMOVE
  161.          '
  162.          ' Do some common stuff.
  163.          '
  164.          GoSub WM_DataExtract
  165.          '
  166.          ' Determine the help message to be displayed.
  167.          '
  168.          If (image_num% < 0) Then
  169.             temp_str$ = ""
  170.          Else
  171.             temp_str$ = gToolbox.icons(gToolbox.tool_selected, (image_num% + 1)).help_str
  172.          End If
  173.          
  174.          
  175.          '
  176.          ' If the left mouse button is depressed, change the icons as needed.
  177.          '
  178.          If (wp And MK_LBUTTON) Then
  179.          
  180.             '
  181.             ' If the image number is different than the index in LastIndexPressed%...
  182.             '
  183.             If (image_num% <> LastIndexPressed%) Then
  184.                '
  185.                ' Set the previously depressed icon to the normal state. (if needed).
  186.                '
  187.                If (LastIndexPressed% > -1) Then
  188.                   frmFlyout!Image1(LastIndexPressed%).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(gToolbox.tool_selected, (LastIndexPressed% + 1)).icon_index)
  189.                End If
  190.                
  191.                '
  192.                ' If the mouse is over one of the icons in the flyout, show the depressed
  193.                ' version of the current icon and set the var LastIndexPressed%.
  194.                ' Otherwise, set the var LastIndexPressed% to -1.
  195.                '
  196.                
  197.                If (image_num% > -1) Then
  198.                   frmFlyout!Image1(image_num%).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(gToolbox.tool_selected, (image_num% + 1)).icon_index + ICON_DEPRESSED)
  199.                   LastIndexPressed% = image_num%
  200.                Else
  201.                   LastIndexPressed% = -1
  202.                End If
  203.             End If
  204.          End If
  205.          
  206.          '
  207.          ' Display the help message in the MDIForm's status line.
  208.          '
  209.          MDIForm1!Panel.Caption = temp_str$
  210.       
  211.       
  212.       '
  213.       ' Left mouse button has been depressed.
  214.       '
  215.       Case WM_LBUTTONDOWN
  216.          '
  217.          ' Do some common stuff.
  218.          '
  219.          GoSub WM_DataExtract
  220.          '
  221.          ' Determine the help message to be displayed.
  222.          '
  223.          If (image_num% < 0) Then
  224.             temp_str$ = ""
  225.          Else
  226.             temp_str$ = gToolbox.icons(gToolbox.tool_selected, (image_num% + 1)).help_str
  227.          End If
  228.          
  229.          
  230.          '
  231.          ' If the image number is different than the index in LastIndexPressed%...
  232.          '
  233.          If (image_num% <> LastIndexPressed%) Then
  234.             '
  235.             ' Set the previously depressed icon to the normal state. (if needed).
  236.             '
  237.             If (LastIndexPressed% > -1) Then
  238.                frmFlyout!Image1(LastIndexPressed%).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(gToolbox.tool_selected, (LastIndexPressed% + 1)).icon_index)
  239.             End If
  240.             
  241.             '
  242.             ' If the mouse is over one of the icons in the flyout, show the depressed
  243.             ' version of the current icon and set the var LastIndexPressed%.
  244.             ' Otherwise, set the var LastIndexPressed% to -1.
  245.             '
  246.             
  247.             If (image_num% > -1) Then
  248.                frmFlyout!Image1(image_num%).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(gToolbox.tool_selected, (image_num% + 1)).icon_index + ICON_DEPRESSED)
  249.                LastIndexPressed% = image_num%
  250.             Else
  251.                LastIndexPressed% = -1
  252.             End If
  253.          End If
  254.          
  255.          '
  256.          ' Display the help message in the MDIForm's status line.
  257.          '
  258.          MDIForm1!Panel.Caption = temp_str$
  259.       '
  260.       ' Left mouse button has been released.
  261.       '
  262.       Case WM_LBUTTONUP
  263.          '
  264.          ' Do some common stuff.
  265.          '
  266.          GoSub WM_DataExtract
  267.          
  268.          '
  269.          ' If the mouse is over an icon, restore it to its normal state.
  270.          '
  271.          If (image_num% > -1) Then
  272.             frmFlyout!Image1(image_num%).Picture = frmToolbox!PicClip1.GraphicCell(gToolbox.icons(gToolbox.tool_selected, (image_num% + 1)).icon_index)
  273.          End If
  274.          
  275.          
  276.          '
  277.          ' Clear the status line in the MDIForm1 window.
  278.          ' Set the LastIndexPressed% var to -1.
  279.          ' Release the mouse capture.
  280.          ' Set the form to sub-class to 0  (stop sub-classing this window).
  281.          ' Post a message to the toolbox indicating what flyout item was selected.
  282.          '
  283.          MDIForm1!Panel.Caption = ""
  284.          LastIndexPressed% = -1
  285.          Call ReleaseCapture
  286.          frmFlyout!SubClass1.HwndParam = 0
  287.          temp% = PostMessage%(frmToolbox.hWnd, WM_USER, image_num%, 0&)
  288.    End Select
  289.    Exit Sub
  290. WM_DataExtract:
  291.    ' Extract the x and y mouse coordinates from the lp parameter.
  292.    Call dwDWORDto2Integers(lp, x%, y%)
  293.    ' Calculate the icon row and column the mouse is over.
  294.    column% = x% \ frmFlyout!Image1(0).Width
  295.    row% = y% \ frmFlyout!Image1(0).Height
  296.    ' Determine the index of the icon the mouse is over.
  297.    ' Take into account the fact that the mouse may be outside the flyout window.
  298.    If ((column% >= gToolbox.flyout_data(gToolbox.tool_selected).num_columns) Or (row% >= gToolbox.flyout_data(gToolbox.tool_selected).num_rows) Or (x% < 0) Or (y% < 0)) Then
  299.       image_num% = -1
  300.    Else
  301.       image_num% = (gToolbox.flyout_data(gToolbox.tool_selected).num_columns * row%) + column%
  302.    End If
  303. Return
  304. End Sub
  305.